package enumdemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class constructor {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
       Class<?> c = Class.forName("enumdemo.TestEnum");

       Constructor<?> con=
               (Constructor) c.getDeclaredConstructor(String.class,int.class,String.class,int.class);
       con.setAccessible(true);
       TestEnum testEnum = (TestEnum) con.newInstance("BLACK",4);
        System.out.println(testEnum);
        /*
        枚举类型无法被反射
         */
    }
}
